<?php 
include("mysqlcon.php");
	$reserv_gid = $_POST['reserv_gid'];
	$cost = $_POST['cost'];
	$roomList = $_POST['roomList'];
	$discList = $_POST['discList'];
	
	$arr = explode ( ",", $roomList );
	$discListArray = explode ( ",", $discList );
	foreach($arr as $k => $v){
		$arr_roomID = trim($v);
		$discSQL = "UPDATE reservation SET reserv_disc = '$discListArray[$k]' WHERE reserv_gid = '$reserv_gid' AND room_id = '$arr_roomID'";
		if(!mysql_query($discSQL)){ echo("ฐานข้อมูลผิดพลาด ".mysql_error()); exit();}
	}
	echo "$reserv_gid : $cost";
	
	$costCommand = "UPDATE reservgroup SET reserv_gcost = $cost WHERE reserv_gid = '$reserv_gid'";
	if(!mysql_query($costCommand)){ echo("ฐานข้อมูลผิดพลาด ".mysql_error()); exit();}
/* 	echo $costCommand; */
?>